package com.neiru.pruebas.ar.thread;

import com.neiru.pruebas.ar.figure.Cube;

public class CubeThread extends Thread {
	private Cube cube;
	public boolean stop = false;
	public CubeThread(Cube cube) {
		this.cube = cube;
	}
	@Override
	public void run() {
		while(!stop) {
			if(cube.rz == 0) {
				cube.ry = 0; 
				cube.rx = 0;
				cube.rz = -90;
			}
			if(cube.rz == -90) {
				cube.y += 0.02;
			} else {
				cube.y -= 0.02;
			}
			if(cube.y > 3 || cube.y < 0 ) {
				cube.rz *=-1;
			}
			try {
				Thread.sleep(10);
			} catch (InterruptedException e) {
				stop = true;
			}
		}
	}
}
